<!DOCTYPE html>
<html>
<head>
    <title>注册</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <link rel="stylesheet" href="${s.base}/mobile/base/css/weui.min.css">
    <link rel="stylesheet" href="${s.base}/mobile/base/css/jquery-weui.css">
    <link rel="stylesheet" href="${s.base}/mobile/base/css/base.css?123456">
    <link rel="stylesheet" href="${s.base}/mobile/base/css/component.css?123456">
    <style type="text/css">
        body, html {
            background: #ffffff;
        }
        .weui-cell {
            padding: 20px 30px;
        }
        .weui-cells{
            line-height: 2;
            font-size: 28px;
        }
        .toolbar .toolbar-inner{
            height: 3.4rem;
        }
        .toolbar .title{
            font-size: 34px;
            line-height: 3.4rem;
        }
        .toolbar .picker-button{
            height: 3.4rem;
            line-height: 3.4rem;
            font-size: 28px;
        }
    </style>
</head>
<body>
<div class="xyg-comp-form">
    <div class="backgroud1">
        <div class="xyg-comp-form-item-two">
            <div class="xyg-comp-form-item-title">
                手机号
            </div>
            <div class="xyg-comp-form-item-content xyg-comp-form-item-yzm">
                <input type="number" id="phone" style="width: 300px;" placeholder="请先输入手机号"/>
                <div class="xyg-comp-yzm" onclick="sendSms()"  id="sendSms">
                    获取验证码
                </div>
            </div>
            <div class="clearBoth"></div>
        </div>
        <div class="xyg-comp-form-item-two">
            <div class="xyg-comp-form-item-title">
                验证码
            </div>
            <div class="xyg-comp-form-item-content">
                <input type="text" id="code" placeholder="请先输入验证码"/>
            </div>
            <div class="clearBoth"></div>
        </div>
        <div class="xyg-comp-form-item-two">
            <div class="xyg-comp-form-item-title">
                身份类型
            </div>
            <div class="xyg-comp-form-item-icon">
                <input type="text" id="cardType" placeholder="请先选择身份类型"/> <span><svg class="icon" aria-hidden="true">
              <use xlink:href="#iconxiangyou"></use>
             </svg> </span>
            </div>
            <div class="clearBoth"></div>
        </div>
        <div class="xyg-comp-form-item-two" id="showShopNumber" <#if webMember.cardType == null || webMember.cardType == "" || webMember.cardType == "1">style="display: none"</#if>>
            <div class="xyg-comp-form-item-title">
                门店代码
            </div>
            <div class="xyg-comp-form-item-content">
                <input type="text" id="shopNumber" placeholder="请先输入门店代码"/>
            </div>
            <div class="clearBoth"></div>
        </div>
        <div class="xyg-comp-form-item-two  margT20">
            <div class="xyg-comp-form-item-title">
                真实姓名
            </div>
            <div class="xyg-comp-form-item-content">
                <input type="text" id="name" placeholder="请先输入真实姓名"/>
            </div>
            <div class="clearBoth"></div>
        </div>
        <div class="xyg-comp-form-item-two">
            <div class="xyg-comp-form-item-title">
                身份证号
            </div>
            <div class="xyg-comp-form-item-content">
                <input type="text" id="idCard" placeholder="请先输入身份证号"/>
            </div>
            <div class="clearBoth"></div>
        </div>
        <div class="xyg-comp-form-item-two">
            <div class="xyg-comp-form-item-title">
                登录密码
            </div>
            <div class="xyg-comp-form-item-content">
                <input type="text" id="password" maxlength="12" placeholder="请先输入6-12位字符串"/>
            </div>
            <div class="clearBoth"></div>
        </div>
    </div>
    <div class="xyg-comp-form-tip color4">
        <input id="checkContract" type="checkbox"/><span onclick="goArticlePage('${memberId}','20190927153123032240283370702087')">同意《渠城中国合作条款》</span>
    </div>
    <div class="margT60 width-b-80">
        <div onclick="submit();"  class="xyg-btn-one backgroud2 color2 ">提交</div>
    </div>

</div>
</body>
<script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
<script src="${s.base}/mobile/base/js/jquery-2.1.4.js"></script>
<script src="${s.base}/mobile/base/js/jquery-weui.js"></script>
<script src="${s.base}/mobile/base/js/swiper.js"></script>
<script src="${s.base}/mobile/base/fonts/iconfont.js"></script>
<script src="${s.base}/mobile/base/js/component.js?123456"></script>
<script src="${s.base}/mobile/base/js/base.js?123456789000"></script>
<script type="text/javascript">
    initXygDpi();

    $(document).ready(function(e) {
        initDate();
    });
    var memberId = '${memberId}';
    function initDate() {
        $("#cardType").select({
            title: "请先选择身份类型",
            items:[{
                title: "门店经纪人",
                value: 2
            },{
                title: "独立经纪人",
                value: 1
            }],
            onChange: function(d) {
                if (d.values == 1) {
                    $("#showShopNumber").hide();
                } else if(d.values == 2) {
                    $("#showShopNumber").show();
                }
            }
        });
    }

    function submit() {



        var phone = $("#phone").val();
        if(phone == null || phone == "") {
            $.toast("请输入手机号", "text");
            return false;
        }else if(!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(phone))){
            $.toast("手机码填写错误", "text");
            return false;
        }
        var code = $("#code").val();
        if (code == null || code == "") {
            $.toast("请输入验证码", "text");
            return false;
        }
        var cardType = $("#cardType").attr("data-values");
        if(cardType == null || cardType == "") {
            $.toast("请选择身份类型", "text");
            return false;
        }
        var shopNumber = $("#shopNumber").val();
        if (cardType == "2") {
            if (shopNumber == null || shopNumber == "") {
                $.toast("请先输入门店代码", "text");
                return false;
            }
        }


        var idCard = $("#idCard").val();
        // 身份证正则
        var idCardTest = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
        if (idCard != null && idCard != "" && !idCardTest.test(idCard)) {
            $.toast("身份证填写格式错误", "text");
            return false;
        }
        /*var bankNo = $("#bankNo").val();
        var bankNoTest = /([\d]{4})([\d]{4})([\d]{4})([\d]{4})([\d]{0,})?/;
        if (bankNo != null && bankNo != "" && !bankNoTest.test(bankNo)) {
            $.toast("银行卡号填写格式错误", "text");
            return false;
        }*/
        var name = $("#name").val();
        if(name == null || name == "") {
            $.toast("请输入姓名", "text");
            return false;
        }
        var password = $("#password").val();
        var passwordTest = /^[a-zA-Z0-9]{6,12}$/;
        if(password == null || password == "") {
            $.toast("请输入登录密码", "text");
            return false;
        }else if(!passwordTest.test(password)) {
            $.toast("登录密码填写错误,请输入6-12位字符串", "text");
            return false;
        }
        if($('#checkContract').is(':checked') == false) {
            $.toast("请同意《渠城中国合作条款》", "text");
            return false;
        }
        $.fn.postMethodResult("/weChat/webMember/register",{'id':memberId,'code':code,'name':name,'cardType':cardType,'phone':phone,
            'password':password,'shopNumber':shopNumber,'idCard':idCard},function (data) {

            $.alert("操作成功",function () {
                goMyPage(memberId);
            });
        });
    }

    var sendFlage=true;//发送标志，true为可以发送
    function sendSms(){
        if(!sendFlage){
            return false;
        }
        sendFlage=false;
        var phone = $("#phone").val();
        if(phone == null || phone == "") {
            $.toast("请输入手机号", "text");
            sendFlage=true;
            return false;
        }else if(!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(phone))){
            $.toast("手机码填写错误", "text");
            sendFlage=true;
            return false;
        }

        $.fn.postBase("/weChat/smsSend",{'phone':phone},function (result) {
            if (result.code === 0) {
                //操作成功
                $.toast("短信发送成功", "text");
                getRandomCode();
            } else {
                sendFlage=false;
                //操作失败
                $.toast(result.msg, "text");
            }
        });
    }

    var time = 60;
    //倒计时
    function getRandomCode() {
        if (time === 0) {
            time = 60;
            sendFlage=true;
            $('#sendSms').html("获取验证码");
            return;
        } else {
            time--;
            $('#sendSms').html(time+"秒");
        }
        setTimeout(function() {
            getRandomCode();
        },1000);
    }

</script>
</html>
